#ifndef APP_STATE_HPP
#define APP_STATE_HPP

class AppState;

class AppStateListener
{
public:
				AppStateListener()			{};
	virtual		~AppStateListener()			{};

	virtual	void	ManageAppState  (Ogre::String stateName, AppState* state) = 0;
	virtual void	ChangeAppState	(AppState *state)		= 0;
	virtual bool	PushAppState	(AppState* state)		= 0;
	virtual void	PopAppState		()						= 0;
	virtual void	PauseAppState	()						= 0;
	virtual void	Shutdown		()						= 0;
    virtual void    PopAllAndPushAppState(AppState* state)	= 0;
	virtual	AppState*	FindByName(Ogre::String stateName)  = 0;
};


class AppState : public OIS::KeyListener, public OIS::MouseListener, public OgreBites::SdkTrayListener
{
public:
	static	void Create(AppStateListener* pParent, const Ogre::String& szName) {};
			void Destroy() { delete this;}

	virtual		void CreateScene()	= 0;
	virtual 	void Enter		()	= 0;
	virtual 	void Exit		()	= 0;
	virtual 	void Update(double fDeltaTime) = 0;
	virtual 	bool Pause		()	{ return true; }
	virtual 	void Resume		()	{};	
	virtual 	void Restart	()	{};	

protected:
			AppState() {};

	AppState*	findByName(const Ogre::String& szStateName);
	void		changeAppState(AppState* pState);
	bool		pushAppState(AppState* pState);
	void		popAppState();
	void		shutdown();
	void        popAllAndPushAppState(AppState* state);

	AppStateListener*			m_pParent;

	Ogre::Camera*				m_pCamera;
	Ogre::SceneManager*			m_pSceneMgr;
    Ogre::FrameEvent            m_FrameEvent;
};

#endif

